var fail_gif = "img/commons/fail_min.gif";
var fail_font_color = "red";
function empity(Msg, Img, Font, FieldName) {
	Msg.style.display = "block";
	Img.src = fail_gif;
	Font.color = fail_font_color;
	Font.size = 3;
	Font.innerHTML = FieldName + "不能为空";
}
function Login() {
	if(CheckEmail()==false) return false;
	if(CheckItem('password','密码')==false) return false;
//	if(CheckCertCode('certcode','验证码')==false) return false;
//	if (md5_vm_test()) {
//		document.getElementById('password').value = hex_md5(document
//				.getElementById('password').value);
//	} else {
//		alert("md5加密模块初始化失败");
//	}
	document.getElementById("login").submit();
}
function CheckEmail() {
	var Email = document.getElementById("email");
	var Msg = document.getElementById("email_div");
	var Img = document.getElementById("email_img");
	var Font = document.getElementById("email_font");
	var pattern = /^([a-zA-Z0-9._-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/;
	;
	if (Email.value == "") {
		empity(Msg, Img, Font, 'E-amil');
		return false;
	} else if (!pattern.test(Email.value)) {
		Msg.style.display = "block";
		Img.src = fail_gif;
		Font.color = fail_font_color;
		Font.innerHTML = "E-mail格式不正确";
		return false;
	} else {
		Msg.style.display = "none";
		Font.innerHTML = "";
		return true;
	}
}
function CheckItem(FieldID, FieldName) {
	var Field = document.getElementById(FieldID);
	var Msg = document.getElementById(FieldID + "_div");
	var Img = document.getElementById(FieldID + "_img");
	var Font = document.getElementById(FieldID + "_font");
	if (Field.value == "") {
		empity(Msg, Img, Font, FieldName);
		return false;
	} else{
		Msg.style.display = "none";
		return true;
	}
}

function ChangCertPic() {
	var certpic = document.getElementById('certpic');
	certpic.src = '/skyline/util/MakeCertPic.jpg?a=' + Math.random();
}